package com.datang.litejvm.attribute;

import com.datang.litejvm.constant.ConstantPool;
import com.datang.litejvm.loader.ByteCodeIterator;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: 顶风少年
 * @Description: 行号
 * @date: 18:29 2022/6/12
 **/
public class LineNumberTable extends AttributeInfo {
	private List<LineNumberItem> items = new ArrayList<LineNumberItem>();
	public LineNumberTable(int attrNameIndex,String attrNameValue, int attrLen) {
		super(attrNameIndex,attrNameValue, attrLen );
	}

	public void parse(ByteCodeIterator iter, ConstantPool pool){
		//成员个数
		int lineNumberLength = iter.nextU2ToInt();
		for (int y = 0; y < lineNumberLength; y++) {
			LineNumberItem lineNumberItem = new LineNumberItem();
			int startPC = iter.nextU2ToInt();
			int lineNum = iter.nextU2ToInt();
			lineNumberItem.setStartPC(startPC);
			lineNumberItem.setLineNum(lineNum);
			items.add(lineNumberItem);
		}
	}
}
